package com.xiaobai.myblog.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class FileNameUtils {
    /**
     * 随机获取名字
     * @return
     */
    public static String createFileName() {
        // 获取随机的五位数
        int rannum = new Random().nextInt(89999) + 10000;
        String nowTimeStr = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        return nowTimeStr + rannum;
    }

    /**
     * 获取输入文件流的扩展名
     *
     * @param fileName
     * @return
     */
    public static String getFileExtension(String fileName) {
        return fileName.substring(fileName.lastIndexOf("."));
    }
}
